home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7260 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  71 lines

  1. Path: titan.fullerton.edu!etezadi
  2. From: etezadi@titan.fullerton.edu (Syrous Etezadi Amoli)
  3. Newsgroups: comp.lang.c++
  4. Subject: What is wrong with the code please?
  5. Date: 22 Feb 1996 09:04:25 GMT
  6. Organization: California State University at Fullerton
  7. Message-ID: <4ghbip$a68@nuke.csu.net>
  8. NNTP-Posting-Host: ecs.fullerton.edu
  9.  
  10. Hi
  11.  
  12. Please tell me what is wrong with the following code which implements a
  13. linked list in BC++ 4.5 with TListImp?
  14.  
  15. #include <classlib\listimp.h>
  16. #include <iostream.h>
  17. #include <String.h>
  18.  
  19. void main()
  20. {
  21.  
  22.  
  23. class CIndexListElement : public: string{
  24.  private:
  25.   string subject;
  26.   long start;
  27.   long end;
  28.  public:
  29.  
  30.   DWORD GetStart(void) {return start;};
  31.   DWORD GetEnd(void) { return end;};
  32.   string GetSubject(void) {return subject;};
  33.   void SetStart(DWORD x) {start = x;};
  34.   void SetEnd(DWORD x) {end = x;};
  35.   void SetSubject(string s) { subject = s;};
  36.   private:
  37.  
  38.  
  39. };
  40. TListImp<CIndexListElement> m_SubjectList;
  41.  
  42. CIndexListElement *new_entry=  new CIndexListElement;
  43. new_entry->SetSubject("1st subject");
  44. new_entry->SetEnd(1);
  45. new_entry->SetStart(1);
  46. m_SubjectList.Add(new_entry);
  47. new_entry->SetSubject("2ND subject");
  48. new_entry->SetEnd(2);
  49. new_entry->SetStart(2);
  50. m_SubjectList.Add(new_entry);
  51. new_entry->SetSubject("3RD subject");
  52. new_entry->SetEnd(3);
  53. new_entry->SetStart(3);
  54. m_SubjectList.Add(new_entry);
  55.  
  56. TListIteratorImp<cIndexListElement> next(m_SubjectList);
  57. cout << "\n The stored items are:\n" << next++;
  58.  
  59. while (next)
  60.   cout << ", " << next++;
  61. cout << endl;
  62. }
  63.  
  64. --
  65.  
  66.   
  67.  
  68. --------------
  69. Syrous Etezadi Amoli (SEA)
  70. etezadi@titan.fullerton.edu
  71.